'''
Company: TWL
Author: xue jian
Email: xuejian@kanzhun.com
Date: 2020-10-27 20:45:55
'''
#
# @lc app=leetcode.cn id=714 lang=python3
#
# [714] 买卖股票的最佳时机含手续费
#

# @lc code=start
class Solution:
    def maxProfit(self, prices: List[int], fee: int) -> int:
        cash=0
        from sys import maxsize
        hold=-maxsize
        for v in prices:
            cash = max(cash, hold+v-fee)
            hold = max(hold, cash-v)
        return cash
# @lc code=end

